<?php
/**
 * Reference Block of an expense
 * To attach the expense to a reference (object,cost center...)
 * 
 */

use Fox\Html\DropList\Radio;
use Hive\Expense\Reference;
use Fox\Generator;
use Fox\Common\Accounting\Controlling\CostCenter;
use Fox\Common\InformationSystem\Project;
use Fox\Html\Input;
use Fox\Dao\SqlFragment;
use Fox\Html\DropList;
use Hive\Expense;

$xview = Xview::instance();

$block = new Fox\Html\Block('bReference',MSG(Expense::MSGCL,2));

// Build Reference Selection List
$finder = new Reference();
$references = $finder->find(new SqlFragment("language = ? AND active = ?",array($xview->language(),1)));

$block->add(new Radio("expense_ref_type",false,true))
		->onChange("toggleReference(this);")
		->options($references,'shortname','label');

// Projects ?
$finder = new Project();
$projects = $finder->find();
$block->add(new DropList(array('project','project_code'),true))
		->hide()
		->options($projects,'projectid','label');
// Cost Center ?
$finder = new CostCenter();
$types = $finder->find();
$block->add(new DropList('costcenter',true))
		->hide()
		->options($types,'costcenterid',Generator::concatenate(
											Generator::useAttribute('code'),
											Generator::useAttribute('label'), ' - '));
// Acitivity ?
//@TODO
return $block;